﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyHoSoCongChung.App_Code.Common;
using QuanLyHoSoCongChung.App_Code.Common.Const;
using System.Globalization;

namespace QuanLyHoSoCongChung.App_Code.Common.Utils
{
    class ProjectUtils
    {
        /// <summary>
        /// Show confirm dialog
        /// </summary>
        /// <param name="strMessage"></param>
        /// <returns></returns>
        public static DialogResult ShowConfirm(string strMessage)
        {
            return MessageBox.Show(strMessage, ResourcesUtils.GetMessage(MessageConst.TITLE_DIALOG_CONFIRM), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
        }

        /// <summary>
        /// Show error alert
        /// </summary>
        /// <param name="strMessage"></param>
        public static void ShowError(string strMessage)
        {
            MessageBox.Show(strMessage, ResourcesUtils.GetMessage(MessageConst.TITLE_DIALOG_ERROR), MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        /// <summary>
        /// Show normal alert
        /// </summary>
        /// <param name="strMessage"></param>
        public static void ShowInfo(string strMessage)
        {
            MessageBox.Show(strMessage, ResourcesUtils.GetMessage(MessageConst.TITLE_DIALOG_INFO), MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        /// <summary>
        /// Show warning
        /// </summary>
        /// <param name="strMessage"></param>
        public static void ShowWarning(string strMessage)
        {
            MessageBox.Show(strMessage, ResourcesUtils.GetMessage(MessageConst.TITLE_DIALOG_WARNING), MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        /// <summary>
        /// Get total bytes of string depending on UTF-8
        /// </summary>
        /// <param name="strSourceData">Input data</param>
        /// <returns></returns>
        public static int GetByteCount(string strSourceData)
        {
            Encoding encoding = Encoding.UTF8;
            return encoding.GetByteCount(strSourceData);
        }

        /// <summary>
        /// Định dạng lưới
        /// </summary>
        /// <param name="dtgv"></param>
        public void SetStyleGrid(DataGridView dtgv)
        {
            dtgv.ReadOnly = true;
            dtgv.MultiSelect = false;
            dtgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
        }
    }
}
